{% extends "admin/base.html" %}

{% block head_block %}
	<script type="text/javascript">
		$(function() {
			$("#lang-tabs").tabs();
		})
	</script>
{% endblock %}

{% block content_block %}
	{{ block.super }}
	<form action="." method="POST">{% csrf_token %}
		<table>
			<tbody>
				<tr>
					<td><label for="name-input">Name:</label></td>
					<td><input id="name-input" type="text" name="name" value="{{ article.name }}" style="width: 400px;"></td>
				</tr>
				<tr>
					<td><label for="is_published-input">Is published:</label></td>
					<td><input id="is_published-input" type="checkbox" name="is_published" {% if article.is_published %}checked="checked"{% endif %}></td>
				</tr>
				<tr>
					<td><label for="is_news-input">Is news:</label></td>
					<td><input id="is_news-input" type="checkbox" name="is_news" {% if article.is_news %}checked="checked"{% endif %}></td>
				</tr>
			</tbody>
		</table>
		<div id="lang-tabs">
			<ul>
				{% for lang in langs %}
					<li><a href="#tabs-{{ lang }}">{{ lang }}</a></li>
				{% endfor %}
			</ul>
			{% if is_add %}
				{% for lang in langs %}
					<div id="tabs-{{ lang }}">
						<table>
							<tr>
								<td>Title:</td>
								<td><input type="text" name="title_{{ lang }}" value=""></td>
							</tr>
							<tr>
								<td>Short text:</td>
								<td><textarea name="short_text_{{ lang }}" rows="4" cols="80"></textarea></td>
							</tr>
							<tr>
								<td>Full text:</td>
								<td><textarea name="full_text_{{ lang }}" rows="15" cols="80"></textarea></td>
							</tr>
						</table>
					</div>
				{% endfor %}
			{% else %}
				{% for atext in article.textes %}
					<div id="tabs-{{ atext.lang }}">
						<table>
							<tr>
								<td>Title:</td>
								<td><input type="text" name="title_{{ atext.lang }}" value="{{ atext.title }}"></td>
							</tr>
							<tr>
								<td>Short text:</td>
								<td><textarea name="short_text_{{ atext.lang }}" rows="4" cols="80">{{ atext.short_text }}</textarea></td>
							</tr>
							<tr>
								<td>Full text:</td>
								<td><textarea name="full_text_{{ atext.lang }}" rows="15" cols="80">{{ atext.text }}</textarea></td>
							</tr>
						</table>
					</div>
				{% endfor %}
			{% endif %}
		</div>
		{% if is_add %}
			<p>
				<input type="submit" name="add" value="Add" class="ui-button">
			</p>
		{% else %}
			<p>
				<input type="submit" name="save" value="Save" class="ui-button">
			</p>
		{% endif %}
	</form>
{% endblock %}